package com.springboot.Controller;

import com.alibaba.fastjson.JSONObject;
import com.springboot.Service.MusicService;
import com.springboot.domain.music;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author 权哥
 * @version 1.0
 * @date 2022/5/19 1:13
 */
@RestController
public class MusicController {

    String keywords="";

    @Autowired
    MusicService musicService;

    @RequestMapping(value = "/keywords",method = RequestMethod.POST)
    public void getResult(@RequestBody JSONObject jsonObject) throws IOException {

        keywords=jsonObject.getString("keywords");
        musicService.getAllSongId(keywords);//传入搜索关键字
        System.out.println(keywords);

    }


    @GetMapping("/getUrl")
    ArrayList<music> geturl(){

        return musicService.getURL();
    }
}
